﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using ZG_member.BLL;
using System.Collections;

namespace ZG_member
{
    public partial class SystemInitialize : Form
    {
        public SystemInitialize()
        {
            InitializeComponent();
            this.Opacity = 0;
        }

        private void btnOK_Click(object sender, EventArgs e)
        {
            if (checkBox6.Checked == true)//用户登陆信息
            {
                usersystemnode node = new usersystemnode();
                DataTable dt = node.GetList("").Tables[0];               
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                  node.DeleteList(dt.Rows[i]["id"].ToString());
                   
                }
            }
            if (checkBox1.Checked == true)//会员信息
            {
                memberInfo info = new memberInfo();
                DataTable dt = info.GetList("").Tables[0];
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    info.DeleteList(dt.Rows[i]["id"].ToString());
                }
            }
            if (checkBox2.Checked == true)//库存商品资料
            {
                goods good = new goods();
                DataTable dt = good.GetList("").Tables[0];
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    good.DeleteList(dt.Rows[i]["id"].ToString());
                }
            }
            if (checkBox3.Checked == true)//进退货流水信息
            {
                goodsflowing flow = new goodsflowing();
                DataTable dt = flow.GetList("").Tables[0];
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    flow.DeleteList(dt.Rows[i]["id"].ToString());
                }
            }
            if (checkBox4.Checked == true)//礼品资料
            {
                gifts gift = new gifts();
                DataTable dt = gift.GetList("").Tables[0];
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    gift.DeleteList(dt.Rows[i]["id"].ToString());
                }
            }
            if (checkBox7.Checked == true)//礼品交易记录
            {
                giftExchangeNotes note = new giftExchangeNotes();
                DataTable dt = note.GetList("").Tables[0];
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    note.DeleteList(dt.Rows[i]["id"].ToString());
                }
            }
            if (checkBox5.Checked == true)
            {
                wasteBook book = new wasteBook();
                DataTable dt = book.GetList("").Tables[0];
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    book.DeleteList(dt.Rows[i]["id"].ToString());
                }
            }


        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            this.timer2.Start();
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            this.Left += 2;
            this.Opacity += 0.1;
            if (Opacity == 1)
            {
                this.timer1.Stop();

            }

        }

        private void timer2_Tick(object sender, EventArgs e)
        {
            this.Top = this.Top + 10;
            this.Opacity = this.Opacity - 0.06;
            if (Opacity <= 0)
            {
                this.timer2.Stop();
                this.Close();
            }
        }

        private void SystemInitialize_Load(object sender, EventArgs e)
        {
            this.timer1.Start();
        }
        int flag = 0;
        private void SystemInitialize_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (flag == 0)
            {
                e.Cancel = true;
                flag = 1;
                this.timer2.Start();
            }
        }
    }
}
